package com.yihusitian.zsxq.sg.config;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;

import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 * @Description 基本信息
 * @Author LeeHo
 * @Date 2020/8/26 13:42
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@XmlRootElement(name="baseinfo")
public class BaseInfo {

    @XmlAttribute
    private String projectLocation;

    @XmlAttribute
    private String javaFileLocation;

    @XmlAttribute
    private String author;

    @XmlAttribute
    private boolean coverOldFile;

    @XmlTransient
    public String getProjectLocation() {
        if (projectLocation == null) {
            projectLocation = Thread.currentThread().getContextClassLoader().getResource("").getPath().replace("/target/classes/", StringUtils.EMPTY);
        }
        return projectLocation;
    }

    @XmlTransient
    public String getJavaFileLocation() {
        return javaFileLocation;
    }

    @XmlTransient
    public String getAuthor() {
        return author;
    }

    @XmlTransient
    public Boolean isCoverOldFile() {
        return coverOldFile;
    }
}